package cn.iocoder.yudao.module.bpm.dal.mysql.journal;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.journal.vo.JournalPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.journal.JournalDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 期刊信息 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface JournalMapper extends BaseMapperX<JournalDO> {

    default PageResult<JournalDO> selectPage(JournalPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<JournalDO>()
                .likeIfPresent(JournalDO::getJournalName, reqVO.getJournalName())
                .eqIfPresent(JournalDO::getJournalCode, reqVO.getJournalCode())
                .eqIfPresent(JournalDO::getSn, reqVO.getSn())
                .eqIfPresent(JournalDO::getJournalFrom, reqVO.getJournalFrom())
                .eqIfPresent(JournalDO::getLanguage, reqVO.getLanguage())
                .eqIfPresent(JournalDO::getFrequency, reqVO.getFrequency())
                .eqIfPresent(JournalDO::getFile, reqVO.getFile())
                .eqIfPresent(JournalDO::getVolumeNumber, reqVO.getVolumeNumber())
                .eqIfPresent(JournalDO::getIssue, reqVO.getIssue())
                .eqIfPresent(JournalDO::getPublishYear, reqVO.getPublishYear())
                .eqIfPresent(JournalDO::getPageRange, reqVO.getPageRange())
                .eqIfPresent(JournalDO::getSource, reqVO.getSource())
                .eqIfPresent(JournalDO::getStatus, reqVO.getStatus())
                .eqIfPresent(JournalDO::getOrderSource, reqVO.getOrderSource())
                .betweenIfPresent(JournalDO::getOrderTime, reqVO.getOrderTime())
                .eqIfPresent(JournalDO::getPosition, reqVO.getPosition())
                .eqIfPresent(JournalDO::getWebUrl, reqVO.getWebUrl())
                .betweenIfPresent(JournalDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(JournalDO::getYwid));
    }

    default List<JournalDO> queryByIds(List<Long> list){
        return selectList(new LambdaQueryWrapperX<JournalDO>()
                .in(JournalDO::getYwid, list));
    };
}